/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.weatherEver.business.boundary;

import it.polimi.weatherEver.business.entity.Notification;
import java.security.Principal;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ettore
 */
@Stateless
public class NotificationManager {

    @PersistenceContext
    EntityManager em;
    
        @Inject
    Principal principal;
        
       public void save(Notification notification) {
        em.persist(notification);
    }

    public void remove() {
        em.remove(getCurrentNotification());
    }

        public Notification getCurrentNotification() {
        return em.find(Notification.class, principal.getName());
    }
    
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
